package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.DTO.InsertUserBankAccountBO;
import com.ruoyi.common.core.domain.DTO.UpdateUserBankAccountBO;
import com.ruoyi.framework.web.service.UserBankAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
public class UserBankAccountController extends BaseController {
    @Autowired
    private UserBankAccountService userBankAccountService;

    @PostMapping("/insertUserBankAccount")
    public AjaxResult insertUserBankAccount(@RequestBody @Valid InsertUserBankAccountBO insertUserBankAccountBO) {
        userBankAccountService.insertUserBankAccount(insertUserBankAccountBO);
        return success();
    }

    @PostMapping("/updateUserBankAccount")
    public AjaxResult updateUserBankAccount(@RequestBody UpdateUserBankAccountBO updateUserBankAccountBO) {
        userBankAccountService.updateUserBankAccount(updateUserBankAccountBO);
        return success();
    }

    @GetMapping("/selectUserBankAccountByUserId/{userId}")
    public AjaxResult selectUserBankAccountByUserId(@PathVariable Long userId) {
        return success().put("data", userBankAccountService.selectUserBankAccountByUserId(userId));
    }
}
